


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html id="htmlId">
<head>
  <title>Coverage Report :: AbstractPropertyAccessStrategy</title>
  <style type="text/css">
    @import "../../.css/coverage.css";
  </style>
</head>

<body>
<div class="header"></div>

<div class="content">
<div class="breadCrumbs">
    [ <a href="../../index.html">all classes</a> ]
    [ <a href="../index.html">at.dormancy.access</a> ]
</div>

<h1>Coverage Summary for Class: AbstractPropertyAccessStrategy (at.dormancy.access)</h1>

<table class="coverageStats">

<tr>
  <th class="name">Class</th>
<th class="coverageStat 
">
  Method, %
</th>
<th class="coverageStat 
">
  Line, %
</th>
</tr>
<tr>
  <td class="name">AbstractPropertyAccessStrategy</td>
<td class="coverageStat">
  <span class="percent">
    100%
  </span>
  <span class="absValue">
    (5/ 5)
  </span>
</td>
<td class="coverageStat">
  <span class="percent">
    100%
  </span>
  <span class="absValue">
    (10/ 10)
  </span>
</td>
</tr>
  <tr>
    <td class="name">AbstractPropertyAccessStrategy$AccessType</td>
<td class="coverageStat">
  <span class="percent">
    100%
  </span>
  <span class="absValue">
    (2/ 2)
  </span>
</td>
<td class="coverageStat">
  <span class="percent">
    100%
  </span>
  <span class="absValue">
    (3/ 3)
  </span>
</td>
  </tr>
<tr>
  <td class="name"><strong>total</strong></td>
<td class="coverageStat">
  <span class="percent">
    100%
  </span>
  <span class="absValue">
    (7/ 7)
  </span>
</td>
<td class="coverageStat">
  <span class="percent">
    100%
  </span>
  <span class="absValue">
    (13/ 13)
  </span>
</td>
</tr>
</table>

<br/>
<br/>


<div class="sourceCode"><i>1</i>&nbsp;/*
<i>2</i>&nbsp; * Copyright 2013 Gregor Schauer
<i>3</i>&nbsp; *
<i>4</i>&nbsp; * Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
<i>5</i>&nbsp; * you may not use this file except in compliance with the License.
<i>6</i>&nbsp; * You may obtain a copy of the License at
<i>7</i>&nbsp; *
<i>8</i>&nbsp; *      http://www.apache.org/licenses/LICENSE-2.0
<i>9</i>&nbsp; *
<i>10</i>&nbsp; * Unless required by applicable law or agreed to in writing, software
<i>11</i>&nbsp; * distributed under the License is distributed on an &quot;AS IS&quot; BASIS,
<i>12</i>&nbsp; * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<i>13</i>&nbsp; * See the License for the specific language governing permissions and
<i>14</i>&nbsp; * limitations under the License.
<i>15</i>&nbsp; */
<i>16</i>&nbsp;package at.dormancy.access;
<i>17</i>&nbsp;
<i>18</i>&nbsp;import org.apache.commons.collections.MapUtils;
<i>19</i>&nbsp;import org.springframework.util.Assert;
<i>20</i>&nbsp;
<i>21</i>&nbsp;import javax.annotation.Nonnull;
<i>22</i>&nbsp;import javax.annotation.Nullable;
<i>23</i>&nbsp;import java.util.HashMap;
<i>24</i>&nbsp;import java.util.Map;
<i>25</i>&nbsp;
<i>26</i>&nbsp;/**
<i>27</i>&nbsp; * Determines how to access entity properties based on various criteria defined by the persistence provider.
<i>28</i>&nbsp; *
<i>29</i>&nbsp; * @author Gregor Schauer
<i>30</i>&nbsp; * @since 2.0.0
<i>31</i>&nbsp; */
<b class="fc"><i>32</i>&nbsp;public abstract class AbstractPropertyAccessStrategy {</b>
<b class="fc"><i>33</i>&nbsp;	protected Map&lt;String, AccessType&gt; propertyAccessTypeMap = new HashMap&lt;String, AccessType&gt;();</b>
<i>34</i>&nbsp;
<i>35</i>&nbsp;	/**
<i>36</i>&nbsp;	 * The access type.
<i>37</i>&nbsp;	 */
<b class="fc"><i>38</i>&nbsp;	public enum AccessType {</b>
<i>39</i>&nbsp;		/** Property-based access is used. */
<b class="fc"><i>40</i>&nbsp;		PROPERTY,</b>
<i>41</i>&nbsp;		/** Field-based access is used. */
<b class="fc"><i>42</i>&nbsp;		FIELD</b>
<i>43</i>&nbsp;	}
<i>44</i>&nbsp;
<i>45</i>&nbsp;	protected AccessType defaultAccessType;
<i>46</i>&nbsp;
<i>47</i>&nbsp;	/**
<i>48</i>&nbsp;	 * Returns the default access mode for the entity type.
<i>49</i>&nbsp;	 *
<i>50</i>&nbsp;	 * @return the access mode
<i>51</i>&nbsp;	 */
<i>52</i>&nbsp;	@Nullable
<i>53</i>&nbsp;	public AccessType getDefaultAccessType() {
<b class="fc"><i>54</i>&nbsp;		return defaultAccessType;</b>
<i>55</i>&nbsp;	}
<i>56</i>&nbsp;
<i>57</i>&nbsp;	/**
<i>58</i>&nbsp;	 * Sets the default access mode for the entity type.
<i>59</i>&nbsp;	 *
<i>60</i>&nbsp;	 * @param defaultAccessType the mode to set
<i>61</i>&nbsp;	 */
<i>62</i>&nbsp;	protected void setDefaultAccessType(@Nullable AccessType defaultAccessType) {
<b class="fc"><i>63</i>&nbsp;		this.defaultAccessType = defaultAccessType;</b>
<b class="fc"><i>64</i>&nbsp;	}</b>
<i>65</i>&nbsp;
<i>66</i>&nbsp;	/**
<i>67</i>&nbsp;	 * Returns the {@link AccessType} for the named property.
<i>68</i>&nbsp;	 *
<i>69</i>&nbsp;	 * @param propertyName the name of the property
<i>70</i>&nbsp;	 * @return the access mode to use
<i>71</i>&nbsp;	 */
<i>72</i>&nbsp;	@Nonnull
<i>73</i>&nbsp;	public AccessType getAccessType(@Nonnull String propertyName) {
<b class="fc"><i>74</i>&nbsp;		AccessType accessType = (AccessType) MapUtils.getObject(propertyAccessTypeMap, propertyName);</b>
<b class="fc"><i>75</i>&nbsp;		Assert.notNull(accessType, &quot;Cannot find property named &#39;&quot; + propertyName + &quot;&#39;&quot;);</b>
<b class="fc"><i>76</i>&nbsp;		return accessType;</b>
<i>77</i>&nbsp;	}
<i>78</i>&nbsp;
<i>79</i>&nbsp;	/**
<i>80</i>&nbsp;	 * Checks whether there is a an accessible property with the given name.
<i>81</i>&nbsp;	 * &lt;p/&gt;
<i>82</i>&nbsp;	 * This method returns {@code true} only if a property with the particular name was detected and its
<i>83</i>&nbsp;	 * {@link AccessType} was defined. In other words, for inaccessible properties this method returns {@code false}.
<i>84</i>&nbsp;	 *
<i>85</i>&nbsp;	 * @param propertyName the name of the property
<i>86</i>&nbsp;	 * @return {@code true} if the object has a property of that name, {@code false} otherwise
<i>87</i>&nbsp;	 */
<i>88</i>&nbsp;	public boolean isProperty(@Nonnull String propertyName) {
<b class="fc"><i>89</i>&nbsp;		return MapUtils.getObject(propertyAccessTypeMap, propertyName) != null;</b>
<i>90</i>&nbsp;	}
<i>91</i>&nbsp;}
</div>
</div>

<div class="footer">
    
    <div style="float:right;">generated on 2013-07-31 23:31</div>
</div>
</body>
</html>
